package com.bank.doman.auth.dao;

import com.bank.common.dao.TkDao;
import com.bank.common.util.MySqlUtil;
import com.bank.doman.auth.dao.mapper.RoleMapper;
import com.bank.doman.auth.dao.model.Role;
import com.bank.doman.auth.io.bo.RoleQueryBo;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 类PermissionDao.java的实现描述：TODO
 *
 * @author zach
 * @Date :2020-06-23 14:40.
 */
@Repository
public class RoleDao extends TkDao<RoleMapper, Role> {

    @Resource
    private RoleMapper roleMapper;

    public Role queryByName(String name){
        Role role = new Role();
        role.setName(name);
        return selectOne(role);
    }

    public List<Role> queryListRole(RoleQueryBo roleQueryBo){
        Example example = getExample();
        example.and().andNotEqualTo("status", roleQueryBo.getStatus())
                .andLike("name", MySqlUtil.allLike(roleQueryBo.getName()))
                .andLike("remark", MySqlUtil.allLike(roleQueryBo.getRemark()));
        return baseMapper.selectByExample(example);
    }

    public List<Role> getAll() {
        Example example = new Example(Role.class);
        return baseMapper.selectByExample(example);
    }

    public void changeId(Map<String, String> map) {
        roleMapper.changeId(map);
    }
}
